package com.njym.java.security.admin.rest;

import com.github.pagehelper.PageHelper;
import com.njym.java.security.admin.biz.FamilyConOrderBiz;
import com.njym.java.security.admin.entity.FamilyConOrder;
import com.njym.java.security.admin.entity.FamilyConOrderVo;
import com.njym.java.security.common.msg.ObjectRestResponse;
import com.njym.java.security.common.rest.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("familyConOrder")
public class FamilyConOrderController extends BaseController<FamilyConOrderBiz,FamilyConOrder> {
    @Autowired
    private FamilyConOrderBiz familyConOrderBiz;

    @RequestMapping(value = "/getList", method = RequestMethod.GET)
    @ResponseBody
    public ObjectRestResponse<FamilyConOrderVo> getList(@RequestParam(defaultValue = "1") int page,
                                                        @RequestParam(defaultValue = "20") int limit,
                                                        Integer conId, String queDescribe, Integer status,
                                                        Integer exigency, String mobile, String acceptAnswerTime){
        PageHelper.startPage(page,limit);
        List<FamilyConOrderVo> rows = familyConOrderBiz.getList(conId, queDescribe, status, exigency, mobile, acceptAnswerTime);

        Integer total = familyConOrderBiz.selectCounts(conId, queDescribe, status, exigency, mobile, acceptAnswerTime);

        Map<String, Object> data = new HashMap<>(2);
        data.put("rows", rows);
        data.put("total", total);
        return new ObjectRestResponse<FamilyConOrderVo>().rel(true).data(data);
    }

}